﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SweetSurvey.Models.Repositories;

namespace SweetSurvey.Models.ViewModels
{
    public class ResultViewModel
    {
        public ResultViewModel(Question question, IAnswerRepository answerRepository, IOptionRepository optionRepository)
        {
            this.QuestionId = question.Id;
            this.Title = question.Title;
            this.Values = new List<int>(answerRepository.GetAnswerCountsByQuestionId(question.Id));
            this.Options = new List<string>();
            var options = optionRepository.GetOptionsByQuestionId(question.Id);
            foreach (var option in options) { this.Options.Add(option.Text); }
        }

        public string QuestionId { get; set; }
        public string Title { get; set; }
        public IList<int> Values { get; set; }
        public IList<string> Options { get; set; }
    }

    public class ResultsViewModel: List<ResultViewModel>
    {
    }
}